import axios from "axios";

const instance = axios.create({
    baseURL: 'http://127.0.0.1:19088'
})

export async function checkLogin() {
    try {
        const response = await instance.post('/api/checkLogin');
        return response.data.code == 1;
    } catch (error) {
        console.error('发送消息出错:', error);
        return false;
    }
}

export async function getContrastList() {
    try {
        const response = await instance.post('/api/getContactList');
        return response.data.code == 1 ? response.data.data : [];
    } catch (error) {
        console.error('发送消息出错:', error);
        return [];
    }
}

export async function sendTextMsg(wxid, msg) {
    try {
        const response = await instance.post('/api/sendTextMsg', { wxid, msg });
        return true;
    } catch (error) {
        console.error('发送消息出错:', error);
        return false;
    }
}

export async function sendImageMsg(wxid, imagePath) {
    try {
        const response = await instance.post('/api/sendImagesMsg', { wxid, imagePath });
        return true;
    } catch (error) {
        console.error('发送消息出错:', error);
        return false;
    }
}

export async function sendFileMsg(wxid, filePath) {
    try {
        const response = await instance.post('/api/sendFileMsg', { wxid, filePath });
        return true;
    } catch (error) {
        console.error('发送消息出错:', error);
        return false;
    }
}

